import { _decorator, Component, Label, Node, UIMeshRenderer } from 'cc';
import { UIMgr } from '../Mgr/UIMgr';
import { AssetList } from '../Global';
import { AudioMgr, SoundName } from '../Mgr/AudioMgr';
import { LocalStorageMgr } from '../Mgr/LocalStorageMgr';
import { GAME_MODE, GAMEDATA } from '../GameScene/GAMEDATA';
const { ccclass, property } = _decorator;

@ccclass('LoginScene')
/**
 * 游戏首页
 */
export class LoginScene extends Component {

    //静音按钮
    @property(Node)
    private MuteButton: Node = null;

    protected start(): void {
        this.MuteButton.active = !AudioMgr.instance.IsBgPlay;
    }

    /**
     * 点击挑战模式
     */
    private ChangeClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);
        this.destroy();
        GAMEDATA.GAME_MODE = GAME_MODE.CHANGE;
        UIMgr.Instance.UdpateScene(AssetList.Scene.GameScene)
    }

    /**
     * 点击普通模式
     */
    private NormalClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);
        this.destroy();
        GAMEDATA.GAME_MODE = GAME_MODE.NORMAL;
        UIMgr.Instance.UdpateScene(AssetList.Scene.GameScene)
    }

    /**
     * 点击计时模式
     */
    private TimeClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);
        this.destroy();
        GAMEDATA.GAME_MODE = GAME_MODE.TIME;
        UIMgr.Instance.UdpateScene(AssetList.Scene.GameScene)
    }

    /**
     * 点击音效按钮
     */
    private SoundClick() {
        AudioMgr.instance.PlayEffect(SoundName.Click);

        AudioMgr.instance.IsBgPlay = !AudioMgr.instance.IsBgPlay
        AudioMgr.instance.IsEffectPlay = AudioMgr.instance.IsBgPlay;
        this.MuteButton.active = !AudioMgr.instance.IsBgPlay;

        if (AudioMgr.instance.IsBgPlay) {
            AudioMgr.instance.PlayBgSound(SoundName.Bg);
        } else {
            AudioMgr.instance.StopBgSound();
        }

    }



}


